package com.ldgame.gfx.gfxelements;

import org.lwjgl.util.vector.Vector2f;
import org.newdawn.slick.Color;

public class Symbol extends Sprite {
	public Symbol(float size, Color color) {
		super(new Vector2f(), size, size, new Vector2f(0.0f, 992.0f), new Vector2f(8.0f, 8.0f), color);
		setTexOffset(0.0f);
	}
	
	private void setSymbol(char symbol) {
		if ((int)symbol > 31 && (int)symbol < 48) {
			symbol -= 32;
			texCoord.x = 8.0f * symbol;
			texCoord.y = 1016.0f;
		} else if ((int)symbol > 47 && (int)symbol < 65) {
			symbol -= 48;
			texCoord.x = 8.0f * symbol;
			texCoord.y = 1008.0f;
		} else if ((int)symbol > 64 && (int)symbol < 91) {
			symbol -= 65;
			texCoord.x = 8.0f * symbol;
			texCoord.y = 992.0f;
		} else if ((int)symbol > 90 && (int)symbol < 97) {
			symbol -= 91;
			texCoord.x = 128.0f + 8.0f * symbol;
			texCoord.y = 1016.0f;
		} else if ((int)symbol > 96 && (int)symbol < 123) {
			symbol -= 97;
			texCoord.x = 8.0f * symbol;
			texCoord.y = 1000.0f;
		}  else if ((int)symbol > 122 && (int)symbol < 127) {
			symbol -= 123;
			texCoord.x = 176.0f + 8.0f * symbol;
			texCoord.y = 1016.0f;
		} else {
			texCoord.x = 248.0f;
			texCoord.y = 1016.0f;
		}
	}
	
	public void render(float posX, float posY, char symbol) {
		position.x = posX;
		position.y = posY;
		setSymbol(symbol);
		
		render();
	}
}
